package com.arron.algorithm.leetcodetop100.贪心;


import org.omg.CORBA.MARSHAL;

/**
 *  将一个正整数n，至少切分为2个整数之和，使得他们乘积最大
 *   https://www.hello-algo.com/chapter_greedy/max_product_cutting_problem/#1
 */
public class 最大切分乘积 {





    public int f(int n){

        if (n<4){
            return n*(n-1);
        }

        int a =  n%3;
        int b = n/3;

        if (a == 0){
            return (int)Math.pow(3,b);
        }

        if (a == 1){
            return (int)Math.pow(3,b-1)*4;
        }

         return (int)Math.pow(3,b)*2;
    }




}
